﻿@using MvcForum.Core.Constants
@model MvcForum.Web.Areas.Admin.ViewModels.RoleListViewModel

@{
    ViewBag.Title = "All Roles";
}

<div class="panel">
    <div class="panel-heading">
        <h5>@ViewBag.Title</h5>
    </div>
    <div class="panel-content">
        <p><label class="label label-danger">Important</label> You must remove all users from a role before you can delete it</p>

        <table class="table table-bordered table-striped">
            <thead>
                <tr>
                    <th>Edit</th>
                    <th>Role</th>
                    <th>Users In Role</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var role in Model.MembershipRoles)
                {
                    var usersCount = role.Users.Count;
                    var hideRole = (role.RoleName == AppConstants.AdminRoleName || role.RoleName == AppConstants.GuestRoleName);

                    if (!hideRole)
                    {
                        <tr>
                            <td>
                                <a href="@Url.Action("EditRole", new { role.Id })" class="btn-mvc">
                                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                </a>
                            </td>
                            <td>@role.RoleName</td>
                            <td>@usersCount</td>
                            <td>
                                <a href="@Url.Action("DeleteRole", new { role.Id })" class="btn-mvc">
                                    <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                                </a>
                            </td>
                        </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</div>



